/*
 * Copyright (C) 2009 Ionut Dediu <deionut@yahoo.com>
 *
 * Licensed under the GNU General Public License Version 2
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// SmartCamAppUi.h

#ifndef __SMARTCAM_APPUI_H__
#define __SMARTCAM_APPUI_H__

// INCLUDES
#include <aknviewappui.h>
#include <aknwaitdialog.h>  // CAknWaitDialog
#include <akniconutils.h>   // For AknIconUtils, MAknIconFileProvider

#include "SmartCamConst.h"
#include "SmartStream.h"
#include "CamFilter.h"
#include "CommFilter.h"

class CAknNavigationDecorator;
class CSmartCamSettingsData;
class CSmartCamSettingsView;
class CSmartCamViewFinderView;

class CSmartCamAppUi : public CAknViewAppUi, public MStreamManager, public MAknIconFileProvider
	{
	public:
		void ConstructL();
		CSmartCamAppUi();
		virtual ~CSmartCamAppUi();

		void HandleSettingsChange();
		// From S60 base classes:
		void HandleCommandL(TInt aCommand);
		void HandleResourceChangeL(TInt aType);
		// From MEikMenuObserver:
        void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
        // From MAknIconFileProvider:
        void RetrieveIconFileHandleL(RFile &aFile, const TIconFileType aType) ;
        void Finished();
		// New functions:
        inline CSmartCamSettingsData& GetSettingsData() { return *iSettingsData; } 
        void EnumerateVideoResolutions(TInt aCameraIndex, RArray<TSize>& aArray);
        void EnumerateVideoFrameRates(TInt aCameraIndex, TInt aResolutionIndex, RArray<TReal32>& aArray);
    	void DisplayMsgL(const TDesC& aMsg);
    	void SetStatusMsg(const TDesC& aMsg);
    	void DisplayFrame(CFbsBitmap* aFrame);
    	CFbsBitmap* ViewFinderFrame();
    	CFbsBitmap* LogoBmp();
    	TDes& GetInetServer();
    	TInt GetInetPort();
    	TDes& GetBtServerAddr();
    	TConnType GetConnectionType();
    	TBool IsConnected();

    	// From MStreamManager:
    	void Start();
    	void Stop();
    	void OpenComplete(MStreamFilter* aFilter, TInt aError, const TDesC& aErrMsg = KNullDesC);
    	void OnFilterError(MStreamFilter* aFilter, TInt aError, const TDesC& aErrMsg = KNullDesC);
// ilyasrk
    	TInt  GetDuration();
		void  SetDuration(TInt n_iDuration);
		TBool IsRunning();
		TBool IsReset();
//		void  SetRepeatMinutesL(const TInt iMinutes);
//		TInt  GetRepeatMinutes();
		TBool StartTimer();
		TBool StopTimer();
		TBool ResetTimer();

	private:
        virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
        CArrayFix<TCoeHelpContext>* HelpContextL() const;

	 	// New functions:
	 	void OpenPipeline();
	 	void LoadSettings();
	 	void SaveSettings();
// ilyasrk
	    static TInt TimerFired(TAny* aPtr);
	    void DoTimerFired();
	    static TInt FlashTimerFired(TAny* aPtr);
	    void DoFlashTimerFired();

	    CPeriodic*                  m_pTimer;                   // Main timer
	    TInt                        m_iTotalDuration;           // Total duration of timer in seconds
	    TInt                        m_iRemainingDuration;       // Seconds remaining to 0

	    CPeriodic*                  m_pFlashTimer;              // Timer to flash screen after notification
	    TBool                       m_bFlash;                   // Flag to specify if screen is flashed
	    
	 	// Data:
	 	RFs iFsSessionSharedProtected;
	 	TFileName iGfxFileName;
	 	TFileName iSettingsFileName;
        CSmartCamSettingsData* iSettingsData;
        CSmartCamSettingsView *iSettingsView;
        CSmartCamViewFinderView *iViewFinderView;

		CCamFilter* iCamFilter;
		TBool iCamFilterOpen;
		CCommFilter* iCommFilter;
		TBool iCommFilterOpen;
		CFbsBitmap* iViewFinderFrame;
		CFbsBitmap* iLogoBmp;
		CAknWaitDialog* iWaitDialog;
		CAknNavigationDecorator* iStatusNav;
	};

#endif//__SMARTCAM_APPUI_H__
